ShopScene={}
ShopSceneFunc={}
ShopSceneFunc.__index = ShopSceneFunc
setmetatable(ShopScene, ShopSceneFunc)

ShopSceneFunc.getNode = function()
  local l = {}
  setmetatable(l, ShopSceneFunc)
  l.node = CCBReader:load("ShopScene.ccbi")
  print("ShopScene.getNode", l.node)
  ShopScene.instance = l
  l:init() 
  return l 
end

ShopSceneFunc.getScene = function()
  local sc = CCScene:create()
  sc:addChild(ShopScene.getNode().node)
  print("ShopScene.getScene", sc)
  return sc
end

ShopSceneFunc.init = function(self)
  setObjectExtTable(self.node:getChildByTag(1111), self)
  self:initTable()
end

ShopSceneFunc.initTable = function(self)
  local items = CCArray:create()
  --for k,v in ipairs(sortedArmys) do
  for i=1, 9 do 
    local item = CCBReader:load("ShopItem.ccbi")
    local b = item:getChildByTag(1020)
    setObjectExtTable(b, self)

    item:setContentSize(CCSizeMake(280, 412))
    items:addObject(item)
  end
  local tableview = CCTableView:create(0, CCSizeMake(810, 420), items)
  tableview:setPosition(70, 90)
  self.node:addChild(tableview)
  self.table = tableview
end

ShopSceneFunc.onBuyButton = function(self, node, event)
  
end

ShopSceneFunc.onClose = function(self, node, event)
  MainScene.scene:removeChild(node:getParent(), true)
  setTouchEnabledAll(MainScene.node, true)
  MainScene.setState()
  ShopScene.instance = nil
end

